<!-- 个人中心 -->
<template>
	<view class="userInfo">
		<view class="cus-title">
			<image class="bg" src="../../static/img/bg1.png" mode=""></image>
			<view class="home-title">个人中心</view>
			<view class="home-person">
				<view class="home-head">
					<image style="width: 100%; height: 100%;" :mode="'aspectFill'"
						:src="'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/6acec660-4f31-11eb-a16f-5b3e54966275.jpg'">
					</image>
					<!-- <image src="../../static/img/1.webp" mode=""></image> -->
				</view>
				<view class="head-det">
					<view class="head-name">{{userInfo?.nickName}}</view>
					<view class="head-samll">{{userInfo?.orgName}}</view>
				</view>
			</view>
			<uni-card>
				<uni-list :border="false">
					<uni-list-item title="账户名称" :rightText="userInfo?.username" />
					<uni-list-item title="类型" :rightText="userInfo.userType=='sys'?'管理员':'商户'" />
					<!-- <uni-list-item title="性质" rightText="合资" /> -->
					<uni-list-item title="账户状态" rightText="正常" />
				</uni-list>
			</uni-card>
			<!-- <uni-list :border="false">
				<uni-list-item showArrow title="关于我们" :border="false">
					<template v-slot:header>
						<uni-icons type="staff-filled" size="20" color="#fb901c"></uni-icons>
					</template>
				</uni-list-item>
				<uni-list-item showArrow title="清除缓存" :border="false">
					<template v-slot:header>
						<uni-icons type="compose" size="20" color="#198a6c"></uni-icons>
					</template>
				</uni-list-item>
			</uni-list> -->
		</view>
		<button class="toLogin" @click="toLogin">退出登录</button>
	</view>
</template>

<script lang="ts" setup>
	import { ref } from 'vue'
	const userInfo = ref({});
	uni.getStorage({
		key: 'userInfo',
		success: function(res) {
			// console.log('123456',res.data);
			userInfo.value = res.data;
		},
		fail: function(res) {
			uni.showToast({
				icon: 'none',
				title: '还未登录，请先登录！',
				duration:500
			});
			setTimeout(()=>{
				uni.redirectTo({
					url: `/pages/login/login`,
				})
			},500)
			
		},
	});
	const toLogin = () => {
		uni.clearStorageSync(); //清除缓存
		uni.clearStorage()
		uni.redirectTo({
			url: '/pages/login/login'
		})
	}
</script>

<style scoped lang="scss">
	.userInfo {
		width: 100%;
		height: 100vh;
		position: relative;
		background-color: #fff;
	}

	.cus-title {
		width: 100%;
		height: 255px;
		// background: url('../../static/img/bg1.png') no-repeat;
		// background-size: 100% auto;
		// background-position: top;
		position: fixed;
		top: 0;
	}
	.bg{
		position: absolute;
		width: 100%;
		z-index: -99;
		object-fit: contain;
	}
	.home-title {
		text-align: center;
		font-size: 16px;
		line-height: 40px;
		color: #fff;
		padding-top: 30px;
	}

	.home-person {
		display: flex;
		align-items: center;
		padding: 20px;
	}

	.home-head {
		width: 50px;
		height: 50px;
		border-radius: 50%;
		overflow: hidden;
	}

	.head-det {
		padding: 0 20px;
		color: #fff;
	}

	.head-name {
		font-size: 18px;
		line-height: 30px;
	}

	.head-samll {
		font-size: 14px;
	}

	.toLogin {
		position: fixed;
		bottom: 10vh;
		width: 60%;
		box-sizing: border-box;
		background-color: #198a6c;
		line-height: 2;
		color: #fff;
		left: 50%;
		transform: translateX(-50%);
		border-radius: 30px;
	}
</style>
